//
//  ChapterModel+CoreDataClass.swift
//  Reader
//
//  Created by wsg on 2019/10/14.
//  Copyright © 2019 codeguesser. All rights reserved.
//
//

import Foundation
import CoreData


public class ChapterModel: NSManagedObject {
    /// 通过书的id获取所有章节
    ///
    /// - Parameters:
    ///   - bid: 书的id
    ///   - context: 要搜索的上下文
    /// - Returns: 获得的对象
    static func models(bid:String, in context:NSManagedObjectContext = .defaultContext())->[ChapterModel]{
        guard bid.isNotEmpty else {
            return []
        }
        return findAll(context: context, predicate: NSPredicate(format: "bid = \(bid)", argumentArray: nil)) ?? []
    }
}
